﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PasswordGenerator;
namespace PasswordGenerator
{
    
    class Program
    {
        
        class RandomPasswordGenerator
        {
            public const string CapitalLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            public const String SmallLetters = "abcdefghijklmnopqrstuvwxyz";
            public const string Digits = "0123456789";
            public const string SpecialChars = "~!@#$%^&*()_+`{}[]\\|':;.,/?<>";
            public const string AllChars = CapitalLetters + SmallLetters + Digits + SpecialChars;
            //public static Random rnd = new Random();
            public static readonly Random rnd = new Random();
            
        }public static string CapitalLetters { get; set; } // tova za vsichko
        static void Main(string[] args)
        {
            StringBuilder password = new StringBuilder();
            for (int i = 1; i <= 2; i++)
            {
                char capitalLetter = GenerateChar(CapitalLetters);
                InsertAtRandomPosition(password, capitalLetter);
            }
            for (int i = 1; i <= 2; i++)
            {
                char smallLetter = GenerateChar(RandomPasswordGenerator.SmallLetters);
                InsertAtRandomPosition(password, smallLetter);
            }
            char digit = GenerateChar(RandomPasswordGenerator.Digits);
            InsertAtRandomPosition(password, digit);
            for (int i = 1; i <= 3; i++)
            {
                char specialChar = GenerateChar(RandomPasswordGenerator.SpecialChars);
                InsertAtRandomPosition(password, specialChar);
            }
            int count = RandomPasswordGenerator.rnd.Next(8);
            for (int i = 1; i <= count; i++)
            {
                char specialChar = GenerateChar(RandomPasswordGenerator.AllChars);
                InsertAtRandomPosition(password, specialChar);
            }
            Console.WriteLine(password);
        }

        private static void InsertAtRandomPosition(StringBuilder password, char character)
        {
            int randomPosition = RandomPasswordGenerator.rnd.Next(password.Length + 1);
            password.Insert(randomPosition, character);
        }
        private static char GenerateChar(string availableChars)
        {
            int randomIndex = RandomPasswordGenerator.rnd.Next(availableChars.Length);
            char randomChar = availableChars[randomIndex];
            return randomChar;
        }


        
    }
}
